package com.blockchainenergy.common.memory.info;

import com.blockchainenergy.common.memory.log.UserMeterLog;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@NoArgsConstructor
public class ElecMeterInfo {
    private String elec_meter_id;

    private Double EA;//总电量
    private Double EF;//正向电量
    private Double ER;//反向电量
    private Double V;//电压
    private Double A;//电流
    private Double PIA;//瞬时有功功率
    private Double PIR;//瞬时无功功率
    private Double PI;//顺时视在功率
    private Double PF;//功率因数

    public ElecMeterInfo(Map.Entry<String, UserMeterLog> meterEntry) {
        UserMeterLog userMeterLog = meterEntry.getValue();
        this.elec_meter_id = meterEntry.getKey();
        if (userMeterLog.getSize() > 0) {
            this.V = userMeterLog.getVs().getLast();
            this.A = userMeterLog.getAs().getLast();
            this.PIR = userMeterLog.getPIRs().getLast();
            this.PIA = userMeterLog.getPIAs().getLast();
        }
    }
}
